﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace Rekenmachine
{
///    <summary>
///     Dit is de driver klasse.
///     Handelt in- en output.
///     Beheert BreukContainer.
///    </summary>
    
    class BreukDriver
    {
        static void Main(string[] args)
        {
            Debug.WriteLine("Starting BreukDriver");
            SpeechLib.SpVoiceClass stem = new SpeechLib.SpVoiceClass();
            stem.Speak("Started driver, please wait", SpeechLib.SpeechVoiceSpeakFlags.SVSFlagsAsync);
            BreukContainer breukContainer = new BreukContainerEenvoudig(0, 10);


            /* String invoer;
            
            do
            {
                int teller;
                int noemer;
                //Teller
                do
                {
                    System.Console.WriteLine("Geef een teller op, of gebruik 's' op te stoppen");
                    invoer = Console.ReadLine();
                } while (!Hulp.isNumeric(invoer, System.Globalization.NumberStyles.Integer) && !invoer.Equals("s", StringComparison.OrdinalIgnoreCase));

                if (invoer.Equals("s", StringComparison.OrdinalIgnoreCase)) break;
                teller = Convert.ToInt32(invoer);

                // Noemer
                do
                {
                    System.Console.WriteLine("Geef een noemer op, of gebruik 's' op te stoppen");
                    invoer = Console.ReadLine();
                } while (!Hulp.isNumeric(invoer, System.Globalization.NumberStyles.Integer) && !invoer.Equals("s", StringComparison.OrdinalIgnoreCase));

                if (invoer.Equals("s", StringComparison.OrdinalIgnoreCase)) break;
                noemer = Convert.ToInt32(invoer);

                breukContainer.AddBreuk(new Breuk(teller, noemer));

            } while (!invoer.Equals("s", StringComparison.OrdinalIgnoreCase));


            System.Console.WriteLine(breukContainer.ToString());
            */

            // x aantal random breuk
            System.Console.WriteLine("\n\n------------------------");
            System.Console.WriteLine("- Willekeurige breuken -");
            System.Console.WriteLine("\n------------------------\n");
            breukContainer.Breuken.RemoveRange(0, breukContainer.Breuken.Count);
            Random ran = new Random();

            int aantal = ran.Next(5, 13);

            for (int i = 0; i < aantal; i++)
            {
                try
                {
                    breukContainer.Add(new Breuk(1, 6, 1, 6));
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.StackTrace);
                    System.Console.WriteLine("Ongeldige invoer");
                }
            }


            System.Console.WriteLine(breukContainer.ToString());
            System.Console.WriteLine("\nDruk op enter om af te sluiten...");

            Console.ReadKey();
        }
    }
}
